// 主界面
;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require("base");
	var leftMenu = require("../leftMenu/leftMenu");
	var topMenu = require("../topMenu/topMenu");
	var footer = require("../footer/footer_main");
	var router = require("../hash/pageRouter");
	var dialog = require("dialog");
	var validate = require("validate");
	var tools = require("tools");
	var storage1 = window.localStorage;
	var s;
	var css_dialog = require("css_dialog");
	var databind = require("databind");
	var html_verify_list = require("./html_verify_list.html");
	var html_receivables_detail = require("./html_receivables_detail.html");
	var html_loan_detail = require("./html_loan_detail.html");
	var html_expense_detail = require("./html_expense_detail.html");
	var storage = window.sessionStorage;
	var constant = require("constant");
	var verifyList = [];
	var html_financingBatchList = require("./html_financingBatchList.html");
	var writeoffId;
	var billReceivableId;
	var type;
	var pageIndex = 1,
		pageSize = 10,
		totalPageCount = 1,
		totalRecordCount = 0; //分页初始化
	var oData = {
		pageIndex: pageIndex,
		pageSize: pageSize,
		totalPageCount: totalPageCount,
		totalRecordCount: totalRecordCount,
		verifiCancelState: false,
		receiptName: ""
	};
	var myData = {};
	var init = function() {
		
		oData = tools.GetRequest(oData, null);
//		type = base.getUrlParam("type");
		type = storage1.getItem("type");
//		writeoffId = base.getUrlParam("writeoffId");
		writeoffId = storage1.getItem("writeoffId");
		footer.init();
		$("#footer").removeClass("none");
		leftMenu.init(5);
		topMenu.init(1);
		router.init();
		$(".table-section").removeClass("none");
		$(".footer").removeClass("none");
		$(".disbursementVerify").parent().parent().parent().addClass("leftMenu-open");
		$(".disbursementVerify").parent().addClass("leftMenu-active");
		tools.requireInput($("#verifyDisbursement"));
		inquireBlankInfoPagelist();
		
		$(".receiptNameDiv").flexbox(CONFIG.ApiPath + CONFIG.ApiVersion + "/inquireEnterpriseListForSelector.json?sessionUuid=" + base.getData("sid") + "&appKey=" + base.getData("appKey"), {
			width: 178,
    		paging: 5,
    		watermark: '请选择收款企业',
    		onSelect: function(){
    			$("#verifyDisbursement input[name=payee]").val($(".receiptNameDiv .ffb-sel").attr("val"));
    			$("#verifyDisbursement input[name=receiptName]").val($(".receiptNameDiv .ffb-sel").attr("val"));
    			inquireEnterpriseBlankInfo($(".receiptNameDiv .ffb-sel").attr("id"));
    			if ($.trim($("input[name=payee]").val()) == "") {
					$("#addDisbursementBtn").hide();
				} else {
					$("#addDisbursementBtn").show();
				}
    		}
		});
		
		if (type == "compile") {
			$("#verifyDisbursement").attr("action", "createBillReceivable");
			$("#verifyDisbursement").append("<input type='hidden' name='billType' value='2' />");
			$("#addDisbursementBtn").remove();
			$("input[name=writeoffAmount]").removeAttr("readonly").attr("name", "amount");
			$("input[name=writeoffDateTime]").parent().html("");
		} else if (type == "verify") {
			$("#addDisbursementBtn").show();
			$("#addDisbursementBtn").removeClass("none");
//			billReceivableId = base.getUrlParam("billReceivableId");
			billReceivableId = storage1.getItem("billReceivableId");
			inquireBillReceivableDetail(billReceivableId);
			databind.disableInput($("#verifyDisbursement"));
			$("input[name=writeoffAmount]").removeAttr("disabled");
			$("input[name=writeoffDateTime]").removeAttr("readonly").removeAttr("disabled");
			$("textarea[name=writeoffRemark]").removeAttr("readonly").removeAttr("disabled");
			$("#undefined_input").attr("disabled", "disabled");
			$("#undefined_arrow").css("pointer-events", "none");
			$(".verifyIntro").remove();
		} else if (type == "detail") {
			billReceivableId = base.getUrlParam("billReceivableId");
//			billReceivableId = storage1.getItem("billReceivableId");
			inquireBillReceivableDetail(billReceivableId);
			databind.disableInput($("#verifyRecepit"));
			$("#verifyRecepitSubmit").hide();
			$(".verifyIntro").hide();
			$("#addReceptBtn").remove();
		} else if (type == "singleVerify") {
//			s = base.getUrlParam("str");
			s = storage1.getItem("str");
			s = decodeURI(decodeURI(s));
			
//			var ri = base.getUrlParam("receiptId");
			var ri = storage1.getItem("receiptId");
//			var rn = decodeURI(base.getUrlParam("receiptName"));
			var rn = decodeURI(decodeURI(storage1.getItem("receiptName")));
			
			$("#verifyDisbursement input[name=payee]").val(rn);
			$("#verifyDisbursement input[name=receiptName]").val(rn);
			$("#verifyDisbursement #undefined_input").val(rn);
			inquireEnterpriseBlankInfo(ri);
			
			$("#addDisbursementBtn").remove();
			$("#verifyDisburseListBody").removeClass("none");
			$("#verifyDisburseListBody").append(s);	
			$("#verifyDisburseListBody tr").removeClass("none");
			var totalAmount = 0;
			$.each($("input[name=verifiAmount]"), function() {
				var $this = $(this);
				totalAmount += $this.val()*1;
			});
			
			$("input[name=writeoffAmount]").val(totalAmount);
		} else if (type == "normal") {
			
		}
		
		initEvent();
	};
	var initEvent = function() {
		//若未登录，则返回登陆页面
		if (base.getData("sid") == null || base.getData("sid") == "" || base.getData("sid") == undefined) {
			location.href = "../login/login.html";
		}
		
		if ($.trim($("input[name=payee]").val()) == "") {
			$("#addDisbursementBtn").hide();
		} else {
			$("#addDisbursementBtn").show();
		}
		
		$("#verifyDisbursement").on("change", "#undefined_input", function(){
			$("#verifyDisbursement input[name=payee]").val($(this).val());
			$("#verifyDisbursement input[name=receiptName]").val($(this).val());
			if ($.trim($("input[name=payee]").val()) == "") {
				$("#addDisbursementBtn").hide();
			} else {
				$("#addDisbursementBtn").show();
			}
		});
		
		tools.clearNoNumAll($("#verifyDisbursement"));
		
		$("#verifyDisbursement").on("change", "input[name=verifiAmount]", function(){
			if ($(this).val()*1 > $(this).attr("amount")*1) {
				base.alert(3, "核销金额不能大于应付金额！");
				$(this).val($(this).attr("amount"));
				return false;
			}
			
			var totalAmount = 0;
			$.each($("input[name=verifiAmount]"), function() {
				var $this = $(this);
				totalAmount += $this.val()*1;
			});
			
			$("input[name=writeoffAmount]").val(totalAmount);
		});
		
		$("#verifyDisbursement select[name=receiptName]").unbind("change").change(function(){
			inquireEnterpriseBlankInfo($("#verifyDisbursement select[name=receiptName] option:selected").attr("enterpriseId"));
		});
		
		$("#verifyDisbursement .receiptNameDiv").unbind("change").change(function(){
			inquireEnterpriseBlankInfo($("#verifyDisbursement select[name=receiptName] option:selected").attr("enterpriseId"));
		});

		$("#leftMenu9").on("click", ".claimManage", function() {
			router.route("claimManage/claimManage.html");
		});

		$("#leftMenu9").on("click", ".insurance1", function() {
			location.href = "../insuranceManage/insuranceManage.html";
		});

		$("#leftMenu9").on("click", ".insurance2", function() {
			location.href = "../insuranceManage/insuranceManage.html";
		});

		$("#leftMenu9").on("click", ".insurance3", function() {
			location.href = "../insuranceManage/insuranceManage.html";
		});

		$("#leftMenu9").on("click", ".insurance4", function() {
			location.href = "../insuranceManage/insuranceManage.html";
		});
		
		$("#verifyDisbursement select[name=accountInfoId]").on("change", function(){
			var $this = $(this);
			$("#verifyDisbursement input[name=disbursementBank]").val($this.find("option:selected").attr("accountbank"));
			$("#verifyDisbursement input[name=disbursementName]").val($this.find("option:selected").attr("accountBankName"));
			$("#verifyDisbursement input[name=drawee]").val($this.find("option:selected").attr("accountBankName"));
			$("#verifyDisbursement input[name=disbursementCreditCard]").val($this.find("option:selected").attr("accountBankCard"));
		});
		
		$("#verifyDisbursement").on("click", ".statementNumber", function() {
			var statementSourceId = $(this).attr("statementSourceId");
			var statementSource = $(this).attr("statementSource");
			switch (statementSource) {
				case "RECEIVABLES":
					$("#popdialog").html(html_receivables_detail);
					dialog.showDialog($("#receivable_detail_dialog"));
					databind.fillInput($("#receivable_detail_dialog"), {
						action: "inquireReceivablesDetail.json?receivablesId=" + statementSourceId
					});
					databind.disableInput($("#receivable_detail_dialog"));
					$(".sure_yes").unbind("click").click(function() {
						dialog.hideDialog($("#receivable_detail_dialog"));
					});

					$(".sure_no").unbind("click").click(function() {
						router.route("financing/receivableNoticeDetail.html?receivablesId=" + statementSourceId);
						dialog.hideDialog($("#receivable_detail_dialog"));
					});
					break;
				case "ABNORMAL_EXPENSE":
					$("#popdialog").html(html_expense_detail);
					dialog.showDialog($("#exception_detail_dialog"));
					tools.inquireCommonSelectorList(9, $(".expenseType"));
					databind.fillInput($("#exception_detail_dialog"), {
						action: "inquireAbnormalExpenseDetail.json?abnormalExpenseId=" + statementSourceId
					});
					databind.disableInput($("#exception_detail_dialog"));
					$(".sure_yes").unbind("click").click(function() {
						dialog.hideDialog($("#exception_detail_dialog"));
					});
					$(".sure_no").unbind("click").click(function() {
						var abnormalId = $("#abnormalId").val();
						dialog.hideDialog($("#exception_detail_dialog"));
						storage.setItem("abnormalId", abnormalId);
						location.href = "../exception/exceptionManage.html#exception/exceptionDetailInfo";
					});
					break;
				case "LOAN_NOTICE":
					$("#popdialog").html(html_loan_detail);
					dialog.showDialog($("#loan_detail_dialog"));
					databind.fillInput($("#loan_detail_dialog"), {
						action: "inquireLoanNoticeDetail.json?loanNoticeId=" + statementSourceId
					});
					databind.disableInput($("#loan_detail_dialog"));
					$(".sure_yes").unbind("click").click(function() {
						dialog.hideDialog($("#loan_detail_dialog"));
					});

					$(".sure_no").unbind("click").click(function() {
						router.route("financing/loanNotice.html?loanNoticeId=" + statementSourceId);
						dialog.hideDialog($("#loan_detail_dialog"));
					});
					break;
				case "INSURANCE":
					router.route("insuranceManage/insuranceDetail.html?insuranceId=" + statementSourceId);
					break;
				case "FINANCE_AUDIT":
					router.route("main/financeApproveDetail.html.html?financeAuditId=" + statementSourceId);
					break;
				default:
					break;
			}
		});
		
		$("#addDisbursementBtn").unbind("click").click(function() {
			$("#popdialog").html(html_verify_list);
			dialog.showDialog($("#verify_list_dialog"));
			$(".searchBox2").removeClass("none");
			oData.receiptName = $("#verifyDisbursement input[name=receiptName]").val();
			tools.loadList("inquireDisbursementMoneyStatementPageList.json", $("#htmlVerifyListTable"), $("#htmlVerifyListTpl1"), oData, function() {
				$("#verify_list_dialog .sure_yes").unbind("click").click(function() {
					$.each($("#verify_list_dialog .moneyStatementId:checked"), function() {
						var $this = $(this);
						var str = '<tr moneystatementId="' + $this.parents("tr").attr("moneystatementId") + '">' + $(this).parents("tr").html() + '<td><input name="verifiAmount" type="text" value="' + $this.parents("tr").attr("balanceAmount") + '" /></td><td><a class="remove">删除</a></td></tr>';
						if (verifyList.indexOf($this.parents("tr").attr("moneystatementId")) < 0) {
							$("#verifyDisburseListBody").removeClass("none");
							verifyList.push($this.parents("tr").attr("moneystatementId"));
							$("#verifyDisburseListBody").append(str);
							$("#verifyDisburseListBody").find("tr td input[type=checkbox]").parent().remove();
						}
					});
					
					var totalAmount = 0;
					$.each($("input[name=verifiAmount]"), function() {
						var $this = $(this);
						totalAmount += $this.val()*1;
					});
					
					$("input[name=writeoffAmount]").val(totalAmount);
					
					dialog.hideDialog($("#verify_list_dialog"));
					$("#verifyDisburseListBody .remove").unbind("click").click(function() {
						var m = $(this).parents("tr").attr("moneyStatementId");
						$.each(verifyList, function(i, v) {
							if (m == v) {
								verifyList.splice($.inArray(v, verifyList), 1);
							}
						});
						$(this).parents("tr").remove();
						if ($("#verifyDisburseListBody tr").length <= 1) {
							$("#verifyDisburseListBody").addClass("none");
						};
						
						var totalAmount = 0;
						$.each($("input[name=verifiAmount]"), function() {
							var $this = $(this);
							totalAmount += $this.val()*1;
						});
						
						$("input[name=writeoffAmount]").val(totalAmount);
					});
				});
				
				$("input[name=verifiAmount]").on("change", function(){
					var totalAmount = 0;
					$.each($("input[name=verifiAmount]"), function() {
						var $this = $(this);
						totalAmount += $this.val()*1;
					});
					
					$("input[name=writeoffAmount]").val(totalAmount);
				});

				$("#verify_list_dialog .sure_no").unbind("click").click(function() {
					dialog.hideDialog($("#verify_list_dialog"));
				});

				$("#verifySearchButton2").unbind("click").click(function() {
					oData.statementBeginDate = $.trim($(".searchBox2 .statementBeginDate").val());
					oData.statementEndDate = $.trim($(".searchBox2 .statementEndDate").val());
					oData.financeNumber = $.trim($(".searchBox2 .financeNumber").val());
					oData.receiptName = $("#verifyDisbursement input[name=receiptName]").val();
					oData.minSourceAmount = $.trim($(".searchBox2 .minSourceAmount").val());
					oData.maxSourceAmount = $.trim($(".searchBox2 .maxSourceAmount").val());
					oData.statementNumber = $.trim($(".searchBox2 .statementNumber").val());

					tools.loadList("inquireDisbursementMoneyStatementPageList.json", $("#htmlVerifyListTable"), $("#htmlVerifyListTpl1"), oData, function() {});
				});
			});
		});
		
		$("#attachFinancingBatch").unbind("click").click(function() {
			$("#popdialog").html(html_financingBatchList);
			dialog.showDialog($("#financingBatch_list_dialog"));
			var oData1 = {
				pageIndex: pageIndex,
				pageSize: pageSize,
				totalPageCount: totalPageCount,
				totalRecordCount: totalRecordCount,
				confirmState: true
			};
			tools.loadList("inquireLonsMoneyInfoList.json", $("#htmlfinancingBatchTable"), $("#htmlfinancingBatchTpl"), oData1, function() {
				$("#financingBatch_list_dialog .sure_yes").unbind("click").click(function() {
					$("#verifyDisbursement input[name=loansMoneyId]").val($("input[name=financingBatchRadio]:checked").parents("tr").attr("loansMoneyId"));
					$(".financeBatch").html("&nbsp;&nbsp;&nbsp;&nbsp;融资批次号：" + $("input[name=financingBatchRadio]:checked").parents("tr").attr("financingbatch"));
					dialog.hideDialog($("#financingBatch_list_dialog"));
				});

				$("#financingBatch_list_dialog .sure_no").unbind("click").click(function() {
					dialog.hideDialog($("#financingBatch_list_dialog"));
				});
				
				$("#financingBatchSearchButton").unbind("click").click(function() {
					oData1.lendUnitName = $.trim($(".searchBox1 .lendUnitName").val());
					oData1.financialBatch = $.trim($(".searchBox1 .financialBatch").val());
					oData1.financingBatch = $.trim($(".searchBox1 .financingBatch").val());
					oData1.startDate = $.trim($(".searchBox1 .startDate").val());
					oData1.endDate = $.trim($(".searchBox1 .endDate").val());
					oData1.maxSourceAmount = $.trim($(".searchBox1 .maxSourceAmount").val());

					tools.loadList("inquireLonsMoneyInfoList.json", $("#htmlfinancingBatchTable"), $("#htmlfinancingBatchTpl"), oData1, function() {});
				});
			}, $("#financingBatch_list_dialog .pagerCon"));
		});

		$("#verifyDisbursementSubmit").unbind("click").click(function() {
			if ($("#verifyDisbursementSubmit input[name=balance]").val() != "" && $("#verifyDisbursementSubmit input[name=writeoffAmount]").val() != null && $("#verifyDisbursementSubmit input[name=writeoffAmount]").val() != "" && $("#verifyDisbursementSubmit input[name=balance]").val()*1 < $("#verifyDisbursementSubmit input[name=writeoffAmount]").val()*1) {
				base.alert(2, "余额不足，不能核销!");
				return;
			}
			databind.submitDom($("#verifyDisbursement"), function() {
				base.alert(1, "提交成功！");
				location.href = "../moneyStatementManage/disbursementManage.html?1=1"+tools.urlEncode(oData, null);
			});
		});
		
		$("#verifyDisbursement").on("click", ".deleteLoanIntro", function() {
			$(this).parent().remove();
			var fileUuids = [];
			$.each($(".showloanIntroDiv"), function() {
				var $this = $(this);
				fileUuids.push($this.find("a").attr("fileUuid"))
			});
			$(".fileUuids").val(fileUuids);
		});
		
		//点击上传附件
		$("#verifyDisbursement").on("change", "#verifyIntro", function() {
			uploadFile();
		});
	};
	
	var inquireBillReceivableDetail = function(billReceivableId) {
		base.fnAjax({
			action: "inquireBillReceivableDetail.json",
			oData: {
				billReceivableId: billReceivableId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					databind.fillForm($("#verifyDisbursement"), data.datas[0]);
					$("#undefined_input").val(data.datas[0].payee);
					
					if (type == "detail") {
						var tpl = $("#verifyDisburseListTpl").html();
						var html = juicer(tpl, data);
						$("#verifyDisburseListBody").html(html);
						$("#verifyDisburseListBody").removeClass("none");
						$(".verifyIntro").remove();
						$("#attachFinancingBatch").remove();
						$("#addDisbursementBtn").remove();
						databind.disableInput($("#verifyDisbursement"));
						$("#verifyDisbursementSubmit").remove();
					} else if (type == "verify") {
						$(".dataLine").removeClass("none");
					}
					
					if ($.trim($("input[name=payee]").val()) == "") {
						$("#addDisbursementBtn").hide();
					} else {
						$("#addDisbursementBtn").show();
					}
					
					$.each(data.datas[0].fileUuid.split(','), function() {
						if (this != "") {
							var str = '<div class="showloanIntroDiv"><a target="_blank" class="mas showloanIntro" fileUuid="' + this + '" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + this + '">' + tools.inquireFile(this) + '</a></div>';
							$("#verifyDisbursement .loan_info4").append(str);
						}
					});
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};
	
	//上传文件
	var uploadFile = function() {
		if ($("#loanIntro").val() != "") {
			$.ajaxFileUpload({
				url: "/finance/api/v1.0/uploadFile.json", //你处理上传文件的服务端
				secureuri: false,
				fileElementId: 'verifyIntro',
				dataType: 'json',
				success: function(data) {
					var str = '<div class="showloanIntroDiv"><a target="_blank" class="mas showloanIntro" fileUuid="' + data.data[0].fileUuid + '" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + data.data[0].fileUuid + '">' + data.data[0].fileName + '</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="deleteLoanIntro">x</a></div>'
					$(".verifyIntro").before(str);
					var fileUuids = [];
					$.each($(".showloanIntroDiv"), function() {
						var $this = $(this);
						fileUuids.push($this.find("a").attr("fileUuid"))
					});
					$(".fileUuids").val(fileUuids);
				},
				complete: function(xml) {
					$("#loanIntro").change(function() {
						uploadFile();
					});
				},
				error: function(data, status, e) {
					if (data.msg == null) {
						base.alert(2, "文件太大无法上传");
					} else {
						base.alert(2, data.msg);
					}
				}
			});
		} else {
			base.alert(3, "请选择文件！");
		}
	};

	var inquireDisbursementWriteoffDetail = function(writeoffId) {
		base.fnAjax({
			action: "inquireDisbursementWriteoffDetail.json",
			oData: {
				writeoffId: writeoffId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					databind.fillForm($("#verifyDisbursement"), data.datas[0]);
					juicer.register("getValueByKey", constant.getValueByKey);
					var tpl = ['<tr>',
						'										<th>收支单号</th>',
						'										<th>单证类型</th>',
						'										<th>应付金额</th>',
						'										<th>余额</th>',
						'										<th>收付款时间</th>',
						'										<th>收款方</th>',
						'										<th>发生金额</th>',
						'									</tr>',
						'									{@each statements as it}',
						'									<tr>',
						'										<td>${it.statementNumber}</td>',
						'										<td>${getValueByKey(44, it.statementSource)}</td>',
						'										<td>&#65509;${it.amount}</td>',
						'										<td>&#65509;${it.disbursementBalance}</td>',
						'										<td>${it.statementDate}</td>',
						'										<td>${it.receiptName}</td>',
						'										<td>${it.disbursementAmount}</td>',
						'									</tr>',
						'									{@/each}'
					].join("");
					var html = juicer(tpl, data.datas[0]);
					$("#verifyDisburseListBody").html(html);
					$("#addDisbursementBtn").remove();
					$("#verifyDisbursementSubmit").html("返回").attr({
						"id": ""
					}).addClass("goBack").unbind("click").click(function() {
						history.go(-1);
					});
					
					$(".verifyIntro").remove();
					$.each(data.datas[0].fileUuid.split(','), function() {
						var str = '<div class="showloanIntroDiv"><a target="_blank" class="mas showloanIntro" fileUuid="' + this + '" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + this + '">' + tools.inquireFile(this) + '</a></div>';
						$("#verifyDisbursement .loan_info4").append(str);
					});

					if ($("#verifyDisburseListBody tr").length > 1) {
						$("#verifyDisburseListBody").removeClass("none");
					}
					databind.disableInput($("#verifyDisbursement"));
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};

	var inquireSystemBlankInfo = function() {
		base.fnAjax({
			action: "inquireSystemBlankInfo.json", //接口名称
			oData: {}, //传递参数
			fnSuccess: function(data) { //成功回调
				if (data.status == 200) {
					$("#verifyDisbursement .disbursementBank").val(data.datas[0].depositBank);
					$("#verifyDisbursement .disbursementName").val(data.datas[0].accountHolder);
					$("#verifyDisbursement .disbursementCreditCard").val(data.datas[0].creditCard);
				}
			}
		});
	};
	
	var inquireBlankInfoPagelist = function() {
		base.fnAjax({
			action: "inquireBlankInfoPagelist.json", //接口名称
			oData: {
				pageSize: 1000
			}, //传递参数
			fnSuccess: function(data) { //成功回调
				if (data.status == 200) {
					$.each(data.datas, function() {
						var str = "<option accountBankName='"+ this.accountBankName +"' accountBankCard='"+ this.accountBankCard +"' accountBank='"+ this.accountBank +"' value='"+ this.accountInfoId +"'>" + this.accountBank + "(" + this.accountBankName + ")" + "</option>";
						$("select[name=accountInfoId]").append(str);
					});
					
					$("#verifyDisbursement input[name=disbursementBank]").val($("select[name=accountInfoId]").find("option:selected").attr("accountbank"));
					$("#verifyDisbursement input[name=disbursementName]").val($("select[name=accountInfoId]").find("option:selected").attr("accountBankName"));
					$("#verifyDisbursement input[name=drawee]").val($("select[name=accountInfoId]").find("option:selected").attr("accountBankName"));
					$("#verifyDisbursement input[name=disbursementCreditCard]").val($("select[name=accountInfoId]").find("option:selected").attr("accountBankCard"));
				}
			}
		});
	};
	
	var inquireEnterpriseBlankInfo = function(enterpriseId) {
		base.fnAjax({
			action: "inquireEnterpriseDetail.json", //接口名称
			oData: {
				enterpriseId: enterpriseId
			}, //传递参数
			fnSuccess: function(data) { //成功回调
				if (data.status == 200) {
					$("#verifyDisbursement input[name=receiptBank]").val(data.datas[0].depositBank);
					$("#verifyDisbursement input[name=receiptCreditCard]").val(data.datas[0].creditCard);
				}
			}
		});
	};

	return {
		init: init
	};
});